function replaceImgWithSwf(element1, element2, width, height){
    width = typeof width !== 'undefined' ? width : 640;
    height = typeof height !== 'undefined' ? height : 480;

    var target_element = document.getElementById(element1),
    obj = document.createElement("object"),
    isMSIE = /*@cc_on!@*/false;
 
    //Add attributes to <object>
    obj.setAttribute("id", "myObjID");
    obj.setAttribute("width", width);
    obj.setAttribute("height", height);
    
    //Add <param> node(s) to <object>
    var param_flashvars = document.createElement("param");
    param_flashvars.setAttribute("name", "flashvars");
    param_flashvars.setAttribute("value", "cat=meow&dog=woof");
    obj.appendChild(param_flashvars);
 
    if (isMSIE) {            
       //IE requires the 'classid' attribute
       obj.setAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
     
       //IE requires the 'movie' <param>
       var param_movie = document.createElement("param");
       param_movie.setAttribute("name", "movie");
       param_movie.setAttribute("value", element2);
       obj.appendChild(param_movie);
     
    } else {
     
       //Non-IE browsers require the 'type' attribute
       obj.setAttribute("type", "application/x-shockwave-flash");
     
       //Non-IE browsers require the 'data' attribute
       obj.setAttribute("data", element2);
     
    }
 
    //Replace targeted DOM element with our new <object>
    target_element.parentNode.replaceChild(obj, target_element);
}